package com.hq.shop10search.config;

import com.hq.commons.constatns.RabbitMQConstatns;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    @Bean
    public FanoutExchange goodsExchange(){
        return new FanoutExchange(RabbitMQConstatns.GOODS_EXCHANGE,true,false);
    }

    @Bean
    public Queue goodsEsQueue(){
        return new Queue(RabbitMQConstatns.GOODS_ES_QUEUE,true,false,false);
    }

    @Bean
    public Binding goodsEsQueueBindGoodsExchange(){
        return BindingBuilder.bind(goodsEsQueue()).to(goodsExchange());
    }
}
